﻿#region Copyright information
// 
// Copyright © 2005-2013 Yongkee Cho. All rights reserved.
// 
// This code is a part of the Biological Object Library and governed under the terms of the
// GNU Lesser General  Public License (LGPL) version 2.1 which accompanies this distribution.
// For more information on the LGPL, please visit http://bol.codeplex.com/license.
// 
// - Filename: TwoSampleTestBase.cs
// - Author: Yongkee Cho
// - Email: yongkeecho@gmail.com
// - Date Created: 2012-09-06 11:39 AM
// - Last Modified: 2013-01-25 3:59 PM
// 
#endregion
using System;
using System.Collections.Generic;
using System.Linq;

namespace BOL.Maths.Statistics.HypothesisTest
{
    public abstract class TwoSampleTestBase<T> : TestBase
    {
        #region Protected variables

        protected T[] Sample1;
        protected int SampleSize1;
        protected T[] Sample2;
        protected int SampleSize2;

        #endregion

        #region Constructor

        protected TwoSampleTestBase(TestType type, double alpha, double nullValue, IEnumerable<T> sample1, IEnumerable<T> sample2)
            : base(type, alpha, nullValue)
        {
            if (sample1 == null)
                throw new ArgumentNullException("sample1");
            if (sample2 == null)
                throw new ArgumentNullException("sample2");

            Sample1 = sample1.ToArray();
            SampleSize1 = Sample1.Length;
            if (SampleSize1 == 0)
                throw new ArgumentException("Sample1 is empty.", "sample1");

            Sample2 = sample2.ToArray();
            SampleSize2 = Sample2.Length;
            if (SampleSize2 == 0)
                throw new ArgumentException("Sample2 is empty.", "sample2");
        }

        #endregion
    }
}
